/**
 *@auther: tang
 *@Date: 2021-02-22
 *Project: p2pPlatformSys
 *Lang: TypeScript
 */
import { Service } from 'egg';
import * as utils from '../utils/utils';

class dictionaryService extends Service {
  async loanUserQuery(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 15;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Loanuser.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async fundsUsages(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbpurpose.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async riskLevels(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbgrade.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async repaymentMethods(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbrepayment.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async debitTypeList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const res:object = await ctx.model.Tbtype.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async guaranteeList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbguarantee.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async pledgeList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbpledge.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async addMoneyList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbaddmoney.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async labelList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tblabel.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async categoryList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Category.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
  async stateList(params:any) {
    const { ctx } = this;
    const page = params.page || 1,
      size = params.size || 30;
    const oriData:any = utils.clearNullItems(params);
    console.log(oriData);
    const res:object = await ctx.model.Tbstate.findAll({
      limit: Number(size),
      offset: (page - 1) * size,
    });
    return res;
  }
}
module.exports = dictionaryService;
